rs=[NaN; est_rs];
sig_rs=[NaN; est_sig_rs];

%%% for robustness with a time-specific tremble parameter
if K_time==1
    kappa_types=NaN(ind_n,1);
    kappa_time=NaN(ind_n,1);
    for z=1:n_type
        temp=kron(ones(ind_n*per_n,1), est_K_time+types(2,z))+kappas(2)*X_s(:,1)+factors*kappas(3:end);
        kappa_types=0.5*normcdf(temp);
        %%% combined kappa by type
        kappa_time(type==z)=kappa_types(type==z);
    end;
else
    kappa_time=kappa;
end


%%% sig_r is the standard deviation of an individual's error term on the
%%% discount rate
sig_r_types=NaN(ind_n,1);
sig_r=NaN(ind_n,1);
for z=1:n_type
    temp=kron(ones(ind_n*per_n,1), types(5,z))+sig_rs(2)*X_s(:,1)+factors*sig_rs(3:end);
    sig_r_types=normcdf(temp);
    %%% combined kappa by type
    sig_r(type==z)=sig_r_types(type==z);
end;

%%% true (or average) discount rate  
r_i_types=NaN(ind_n,1); 
r_i=NaN(ind_n,1);
for z=1:n_type
    temp=kron(ones(ind_n*per_n,1), types(4,z))+rs(2)*X_s(:,1)+factors*rs(3:end);
    r_i_types=r_scale*normcdf(temp);
    %%% combined kappa by type
    r_i(type==z)=r_i_types(type==z);
end;


